#include "processtable.h"
#include <map>
#include "process.h"

ProcessTable::ProcessTable()
{
	processMap = new map<int, Process *>;
}

ProcessTable::~ProcessTable()
{
	delete processMap;
}
void ProcessTable::addProcess(int x, Process * t)
{
  
   processMap->insert(pair<int, Process *>(x,t));
  //Added a process to the map.
}


void ProcessTable::removeProcess(int id)
{
  
  processMap->erase(id);
  //Removing a process from the map
}


Process * ProcessTable::getProcess(int id)
{
  bool found = false;
  printf("heres ");
  map <int, Process *>::iterator is;
  for(is = processMap->begin();is != processMap->end(); ++is){
    if((is == processMap->find(id)))
	{
	  return is->second;
	}
  }
  printf("Here'sitgo");
  return NULL;
}

bool  ProcessTable::checkProcess(int id)
{
  bool found = false;
  map <int, Process *>::iterator is;
  for(is = processMap->begin();is != processMap->end(); ++is){
    if((is == processMap->find(id)))
	{
	  found = true;
	  break;
	}
  }
  return found;
}


int ProcessTable::getSize()
{
  processMap->size();

}

